<?php
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
use Think\StaticRouteAppID;

class IndexController extends AdminbaseController {
    public function _initialize() {
        parent::_initialize();
    }
    public function index(){
        if(sp_is_mobile()){
            redirect(U("Mobile/Index/index"));     
        }
        $user = M('User')->find(get_current_admin_id());
        $appIdStr = implode(',',StaticRouteAppID::getAppIdArray());
        $roleWhere['r.AppID'] = array('in',$appIdStr);
        $roleWhere['rel.UserID'] = array('eq',get_current_admin_id());
        $roleField = 'r.*';
        $roleList = M('Role as r')->join('left join Role_user_rel as rel on rel.RoleID=r.ID')
            ->where($roleWhere)->field($roleField)->select();
        $this->assign('user',$user);
        $this->assign('roleList',$roleList);
        $this->display('index');
    }

    
}